package main

import (
	"net/http"
	"log"

	// 导入服务实现包
	calculatorv1 "example.com/calculator/calculator/v1"
	// 导入 connect 处理器包
	calculatorv1connect "example.com/calculator/calculator/v1/calculatorv1connect"
	"golang.org/x/net/http2"
	"golang.org/x/net/http2/h2c"
)

func main() {
	// 创建服务实例
	calcService := &calculatorv1.CalculatorService{}
	
	mux := http.NewServeMux()
	// 注册服务处理器
	path, handler := calculatorv1connect.NewCalculatorServiceHandler(calcService)
	mux.Handle(path, handler)
	
	server := &http.Server{
		Addr:    ":8080",
		Handler: h2c.NewHandler(mux, &http2.Server{}),
	}
	
	log.Println("Server starting on :8080...")
	if err := server.ListenAndServe(); err != nil {
		log.Fatalf("Server failed to start: %v", err)
	}
}